import { createRouter, createWebHistory } from 'vue-router'
import HomePage from '@/pages/HomePage.vue'
import {
  HomeOutlined,
  BookOutlined,
  FormOutlined,
  BarChartOutlined,
  FolderOutlined,
  RobotOutlined,
  SolutionOutlined,
  DashboardOutlined,
  TeamOutlined,
  DatabaseOutlined,
  SettingOutlined,
  FilePptOutlined,
  GlobalOutlined,
  CodepenOutlined,
  OrderedListOutlined,
  DiffOutlined,
  PictureOutlined,
  VideoCameraOutlined,
} from '@ant-design/icons-vue'
import UserLoginPage from '@/pages/user/UserLoginPage.vue'
import UserRegisterPage from '@/pages/user/UserRegisterPage.vue'
import UserForgotPasswordPage from '@/pages/user/UserForgotPasswordPage.vue'
import LearningAssistantPage from '@/pages/student/LearningAssistantPage.vue'
import ACCESS_ENUM from '@/utils/access/ACCESS_ENUM'
import PracticeAssistantPage from '@/pages/student/PracticeAssistantPage.vue'
import ErrorPracticePage from '@/pages/student/ErrorPracticePage.vue'
import DoExamPage from '@/pages/student/DoExamPage.vue'
import CourseDesignPage from '@/pages/teacher/wisdomprecourse/CourseDesignPage.vue'
import ExamGenerationPage from '@/pages/teacher/examgeneration/ExamGenerationPage.vue'
import StudentAnalysisPage from '@/pages/teacher/StudentAnalysisPage.vue'
import DashboardPage from '@/pages/admin/DashboardPage.vue'
import ResourceAdminPage from '@/pages/admin/ResourceAdminPage.vue'
import UserManagementPage from '@/pages/admin/UserManagementPage.vue'
import ResourceManagement from '@/pages/teacher/collaborativespace/ResourceManagement.vue'
import CourseDesignEditPage from '@/pages/teacher/wisdomprecourse/CourseDesignEditPage.vue'
import GenerateExamEditPage from '@/pages/teacher/examgeneration/GenerateExamEditPage.vue'
import AdminLayout from '@/layouts/AdminLayout.vue'
import PromptManagementPage from '@/pages/admin/PromptManagementPage.vue'
import UserCenterPage from '@/pages/user/UserCenterPage.vue'
import ProgramQuestionPage from '@/pages/student/ProgramQuestionPage.vue'
import PracticeProgramPage from '@/pages/student/PracticeProgramPage.vue'
import MindMapPage from '@/pages/user/MindMapPage.vue'
import DocumentDiffPage from '@/pages/teacher/collaborativespace/DocumentDiffPage.vue'
import CollaborativeEditPage from '@/pages/teacher/collaborativespace/CollaborativeEditPage.vue'
import PictureModalPage from '@/pages/teacher/multimodal/PictureModalPage.vue'
import VedioModalPage from '@/pages/teacher/multimodal/VedioModalPage.vue'
import CollaborativePage from '@/pages/teacher/collaborativespace/CollaborativePage.vue'
import NewKnowledgeGraphPage from '@/pages/teacher/wisdomprecourse/NewKnowledgeGraphPage.vue'
import OldGeneratePPTPage from '@/pages/teacher/wisdomprecourse/OldGeneratePPTPage.vue'
import MyTeachClassPageCopy from '@/pages/teacher/teachclass/MyTeachClassPageCopy.vue'
import DoExercisesPage from '@/pages/student/DoExercisesPage.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: '主页',
      component: HomePage,
      meta: {
        icon: HomeOutlined,
      },
    },
    {
      path: '/user/login',
      name: '用户登录',
      component: UserLoginPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/user/register',
      name: '用户注册',
      component: UserRegisterPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/user/forgot-password',
      name: '忘记密码',
      component: UserForgotPasswordPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/user/center',
      name: '用户中心',
      component: UserCenterPage,
      meta: {
        hideInMenu: true,
      },
    },
    {
      path: '/user/view_md/:id?',
      name: '文档中心',
      component: () => import('@/pages/user/UserMDPage.vue'),
      // 关键：用props函数整合路径参数、查询参数（支持加密token和业务标识）
      props: (route) => ({
        // 路径参数：原id（可作为默认业务的id，或备用）
        baseId: route.params.id,
        // 查询参数：加密token（用于加密场景）
        token: route.query.token,
        // 查询参数：业务类型（非加密场景，如doc/order等）
        bizType: route.query.bizType,
        // 查询参数：业务id（非加密场景，覆盖baseId）
        bizId: route.query.bizId,
      }),
      meta: {
        icon: BookOutlined,
        hideInMenu: true,
      },
    },

    {
      path: '/student/learning_assistant',
      name: '学习助手',
      component: LearningAssistantPage,
      meta: {
        access: ACCESS_ENUM.STUDENT,
        icon: RobotOutlined,
      },
    },
    {
      path: '/student/practice_assistant',
      name: '实时练习评测助手',
      component: PracticeAssistantPage,
      meta: {
        access: ACCESS_ENUM.STUDENT,
        icon: SolutionOutlined,
      },
    },
    {
      path: '/student/practice_program/:id',
      name: '编程练习',
      component: PracticeProgramPage,
      props: true,
      meta: {
        access: ACCESS_ENUM.STUDENT,
        icon: SolutionOutlined,
        hideInMenu: true,
      },
    },
    {
      path: '/student/program_question',
      name: '编程刷题',
      component: ProgramQuestionPage,
      meta: {
        access: ACCESS_ENUM.STUDENT,
        icon: CodepenOutlined,
      },
    },
    {
      path: '/student/error_practice',
      name: '错题集',
      component: ErrorPracticePage,
      meta: {
        access: ACCESS_ENUM.STUDENT,
        icon: SolutionOutlined,
        hideInMenu: true,
      },
    },
    {
      path: '/student/do_exam',
      name: '测试练习',
      component: DoExamPage,
      meta: {
        access: ACCESS_ENUM.STUDENT,
        icon: FormOutlined,
        hideInMenu: true,
      },
    },
    {
      path: '/student/do_exercise',
      name: '练习训练',
      component: DoExercisesPage,
      meta: {
        access: ACCESS_ENUM.STUDENT,
        icon: FormOutlined,
        // hideInMenu: true,
      },
    },
    {
      path: '/teacher/course_design',
      name: '备课与设计',
      component: CourseDesignPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: BookOutlined,
      },
    },
    {
      path: '/teacher/course_design/edit/:id',
      name: '备课与设计编辑',
      component: CourseDesignEditPage,
      props: true,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        hideInMenu: true,
      },
    },
    {
      path: '/teacher/generate_ppt',
      name: '智能ppt',
      component: OldGeneratePPTPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: FilePptOutlined,
        // hideInMenu: true,
      },
    },
    // {
    //   path: '/teacher/previewDemo',
    //   name: '文件预览demo',
    //   component: Demo,
    //   meta: {
    //     access: ACCESS_ENUM.TEACHER,
    //     icon: FilePptOutlined,
    //     // hideInMenu: true,
    //   },
    // },
    // {
    //   path: '/teacher/generate_knowledgeGraph',
    //   name: '智能生成知识图谱',
    //   component: KnowledgeGraphPage,
    //
    //   meta: {
    //     access: ACCESS_ENUM.TEACHER,
    //     icon: GlobalOutlined,
    //     // hideInMenu: true,
    //   },
    // },
    {
      path: '/teacher/generate_knowledgeGraph',
      name: '知识图谱',
      component: NewKnowledgeGraphPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: GlobalOutlined,
        // hideInMenu: true,
      },
    },
    {
      path: '/user/markmap',
      name: '思维导图',
      component: MindMapPage,
      meta: {
        access: ACCESS_ENUM.TEACHER || ACCESS_ENUM.STUDENT,
        icon: OrderedListOutlined,
      },
    },
    {
      path: '/teacher/exam_generation',
      name: '考核内容生成',
      component: ExamGenerationPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: FormOutlined,
      },
    },
    {
      path: '/teacher/exam_generation/edit/:id',
      name: '编辑考核内容',
      component: GenerateExamEditPage,
      props: true,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        hideInMenu: true,
      },
    },
    {
      path: '/teacher/resourceManagement',
      name: '我的资源',
      component: ResourceManagement,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: FolderOutlined,
      },
    },
    {
      path: '/teacher/document_diff',
      name: '文档差异',
      component: DocumentDiffPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: DiffOutlined,
      },
    },
    {
      path: '/teacher/collaborative_space',
      name: '协同空间',
      component: CollaborativePage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: TeamOutlined,
      },
    },
    {
      path: '/teacher/collaborative_edit',
      name: '协同编辑',
      component: CollaborativeEditPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: TeamOutlined,
        hideInMenu: true,
      },
    },
    {
      path: '/teacher/picture_generation',
      name: '图片教学',
      component: PictureModalPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: PictureOutlined,
      },
    },
    {
      path: '/teacher/video_generation',
      name: '视频教学',
      component: VedioModalPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: VideoCameraOutlined,
      },
    },
    {
      path: '/teacher/teach_class',
      name: '教学班级',
      component: MyTeachClassPageCopy,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: BarChartOutlined,
      },
    },
    {
      path: '/teacher/student_analysis',
      name: '学情数据分析',
      component: StudentAnalysisPage,
      meta: {
        access: ACCESS_ENUM.TEACHER,
        icon: BarChartOutlined,
      },
    },
    {
      path: '/admin/system_management',
      name: '系统管理',
      component: AdminLayout,
      meta: {
        access: ACCESS_ENUM.ADMIN,
        icon: SettingOutlined,
      },
      children: [
        {
          path: '/admin/dashboard',
          name: '控制台',
          component: DashboardPage,
          meta: {
            access: ACCESS_ENUM.ADMIN,
            icon: DashboardOutlined,
            hideInMenu: true,
          },
        },
        {
          path: '/admin/resource_admin',
          name: '资源管理',
          component: ResourceAdminPage,
          meta: {
            access: ACCESS_ENUM.ADMIN,
            icon: DatabaseOutlined,
            hideInMenu: true,
          },
        },
        {
          path: '/admin/user_management',
          name: '用户管理',
          component: UserManagementPage,
          meta: {
            access: ACCESS_ENUM.ADMIN,
            icon: TeamOutlined,
            hideInMenu: true,
          },
        },
        {
          path: '/admin/prompt_management',
          name: '提示词管理',
          component: PromptManagementPage,
          meta: {
            access: ACCESS_ENUM.ADMIN,
            icon: BookOutlined,
            hideInMenu: true,
          },
        },
      ],
    },
  ],
})

export default router
